import { HttpUrlVariable } from '@/constants'
import type {
  CreateOrderResult,
  DepartData,
  OrderDetailData,
  OrderDetailParams,
  OrderParams,
  OrderPreData,
  OrderPreParams,
  PayParams,
  PayResult,
} from '@/types/consult'
import RequestHttp from '@/utils/request'

export const getConsultListAPI = () =>
  RequestHttp.get<DepartData[]>(HttpUrlVariable.CONSULT_LIST_URL)

/**
 * 获取预订单信息
 * **/
export const getPreOrderAPI = (params: OrderPreParams) =>
  RequestHttp.get<OrderPreData, OrderPreParams>(HttpUrlVariable.PRE_ORDER_URL, params)

/**
 * 创建订单接口
 * **/
export const createOrderAPI = (data: OrderParams) =>
  RequestHttp.post<CreateOrderResult, OrderParams>(HttpUrlVariable.CREATE_ORDER_URL, data)

/***
 * 支付接口
 * **/
export const payAPI = (data: PayParams) =>
  RequestHttp.post<PayResult, PayParams>(HttpUrlVariable.PAY_URL, data)

// 获取订单详情
export const getOrderDetailAPI = (orderId: string) =>
  RequestHttp.get<OrderDetailData, OrderDetailParams>(HttpUrlVariable.ORDER_DETAIL_URL, {
    orderId,
  })
